package org.linlinjava.litemall.db.service;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LumiereCloverCardMapper;
import org.linlinjava.litemall.db.domain.LumiereCloverCard;
import org.linlinjava.litemall.db.domain.LumiereCloverCardExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LumiereCloverCardService extends MPJBaseServiceImpl<LumiereCloverCardMapper,LumiereCloverCard> {
    @Resource
    private LumiereCloverCardMapper lumiereCloverCardMapper;

    public List<LumiereCloverCard> listByUserId(Integer userId){
        LumiereCloverCardExample example = new LumiereCloverCardExample();
        example.or().andUserIdEqualTo(userId);

        return lumiereCloverCardMapper.selectByExample(example);
    }

    public int insert(LumiereCloverCard cloverCard){
        return lumiereCloverCardMapper.insert(cloverCard);
    }

    public LumiereCloverCard findByCardNumber(String cardNumber,Integer userId){
        LumiereCloverCardExample example = new LumiereCloverCardExample();
        example.or().andCardNumberEqualTo(cardNumber).andUserIdEqualTo(userId);
        return  lumiereCloverCardMapper.selectOneByExample(example);
    }

    public LumiereCloverCard findByUserId(Integer userId){
        /*LumiereCloverCardExample example = new LumiereCloverCardExample();
        example.or().andUserIdEqualTo(userId);
        return  lumiereCloverCardMapper.selectOneByExample(example);*/
        return lumiereCloverCardMapper.findByUserId(userId);
    }

    public int update(LumiereCloverCard cloverCard){
        return lumiereCloverCardMapper.updateByPrimaryKey(cloverCard);
    }


}
